﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
    //Layout = "~/Views/Shared/_Index.cshtml";
} 
<script>
    $(function () {
        gridList();
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            treeGrid: true,
            treeGridModel: "adjacency",
            ExpandColumn: "UrlAddress",
            url: "/SystemManage/SysModule/GetTreeGridJson",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "Id", hidden: true, key: true },
                { label: '名称', name: 'FullName', width: 200, align: 'left' },
                { label: '连接', name: 'UrlAddress', width: 260, align: 'left' },
                {
                    label: '目标', name: 'Target', width: 80, align: 'center',
                    formatter: function (cellvalue) {
                        if (cellvalue === "expand") {
                            return "导航栏";
                        } else if (cellvalue === "iframe") {
                            return "框架页";
                        } else if (cellvalue === "open") {
                            return "弹出页";
                        } else if (cellvalue === "blank") {
                            return "新窗口";
                        } else
                            return "";
                    }
                },
                //{
                //    label: "菜单", name: "IsMenu", width: 60, align: "center",
                //    formatter: function (cellvalue) {
                //        return cellvalue === true ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                //    }
                //},
                //{
                //    label: "展开", name: "IsExpand", width: 60, align: "center",
                //    formatter: function (cellvalue) {
                //        return cellvalue === true ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                //    }
                //},
                //{
                //    label: "公共", name: "IsPublic", width: 60, align: "center",
                //    formatter: function (cellvalue) {
                //        return cellvalue === true ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                //    }
                //},
                {
                    label: "有效", name: "EnabledMark", width: 60, align: "center",
                    formatter: function (cellvalue) {
                        return cellvalue === true ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                    }
                },
                { label: '介绍', name: 'Description', width: 300, align: 'left' }
            ],
            pager: "#gridPager",
            sortname: 'SortCode',
            rowNum: 20,
            rowList: [20, 50, 100, 200],
            viewrecords: true

        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() }
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增菜单",
            url: "/SystemManage/SysModule/Form",
            width: "700px",
            height: "440px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_addParent() {
        var keyValue = $("#gridList").jqGridRowValue().Id;
        $.modalOpen({
            id: "Form",
            title: "新增菜单",
            url: "/SystemManage/SysModule/Form?parentId=" + keyValue,
            width: "700px",
            height: "440px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().Id;
        $.modalOpen({
            id: "Form",
            title: "修改菜单",
            url: "/SystemManage/SysModule/Form?keyValue=" + keyValue,
            width: "700px",
            height: "440px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/SystemManage/SysModule/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().Id },
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }
 
    function btn_modulebutton() {
        var keyValue = $("#gridList").jqGridRowValue().Id;
        $.modalOpen({ 
            id: "SysModuleAuthorize",
            title: "权限管理",
            url: "/SystemManage/SysModuleAuthorize/Index?ParentUrl=SysModuleAuthorize&moduleid=" + keyValue,
            width: "880px",
            height: "600px",
            btn: null
        });
    }
</script>

<div class="topPanel">
    <div class="toolbar"> 
        <div class="btn-group">
            <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建菜单</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-addParent" authorize="yes" class="fa fa-primary" onclick="btn_addParent()"><i class="fa fa-plus"></i>新建菜单</a></li> 
                <li><a id="NF-edit" authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改菜单</a></li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除菜单</a></li> 
                <li class="split"></li>
                <li><a id="NF-modulebutton" authorize="yes" onclick="btn_modulebutton()"><i class="fa fa-gavel"></i>权限管理</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
       <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
</div>
